package com.wink.admin.entity;


import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.sql.Timestamp;


/**
 * 基础实体类
 *
 * @author xw
 * @date 2020/10/27 11:39
 */
@MappedSuperclass
@Data
public abstract class BaseEntity implements Serializable {
    private static final long serialVersionUID = -250118731239275742L;

    @Id
    @TableId
    @Column(name = "id", columnDefinition = ("bigint not null comment '主键ID'"))
    private Long id;

    @Column(name = "is_deleted", columnDefinition = ("tinyint(4) not null default 0 comment '是否删除'"))
    @TableLogic
    private Integer isDeleted;

    @TableField(value = "created_date", fill = FieldFill.INSERT)
    @Column(name = "created_date", columnDefinition = ("timestamp not null default current_timestamp comment '创建时间'"))
    private Timestamp createdDate;

    @TableField(value = "last_modify_date", fill = FieldFill.INSERT_UPDATE)
    @Column(name = "last_modify_date", columnDefinition = ("timestamp not null default current_timestamp on update current_timestamp comment '最后修改时间'"))
    private Timestamp lastModifyDate;

    @TableField(value = "updated_by", fill = FieldFill.INSERT_UPDATE)
    @Column(name = "updated_by", columnDefinition = ("varchar(50) not null default '系统默认角色' comment '修改人'"))
    private String updatedBy;
}
